package controller;

import dao.LoginDao;
import javafx.fxml.FXML;
import javafx.scene.control.PasswordField;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.stage.Stage;
import view.AdminFrame;
import view.MainFrame;
import view.RegisterFrame;

import javax.swing.*;
import java.io.IOException;

/**
 * @author :wn
 * @program : 管家婆项目
 * @descript : 登录界面控制器
 * @create :2020-06-07 11:03
 */

public class LoggerFrame {

    @FXML
    private TextField username;
    @FXML
    private PasswordField passwordField;
   LoginDao loginDao=new LoginDao();
    public  void logaction()throws Exception{

       String   name=username.getText();
       String  password=passwordField.getText();
       if(name.equals("")){
           JOptionPane.showMessageDialog(null,"请先注册");
       }else {
           boolean loginbuttonactive = loginDao.loginQuery(name, password);
           if (loginbuttonactive == true) {
               MainFrame.stage.close();
               AdminFrame adminFrame = new AdminFrame();
               adminFrame.start(new Stage());
           } else {
               JOptionPane.showMessageDialog(null, "用户名或者密码错误！！！\n请重新输入！！！");
           }
       }
    }
    public void Register() throws IOException {
        RegisterFrame registerFrame=new RegisterFrame();
        registerFrame.start(new Stage());
    }
}
